var pageii = null;
var grid = null;
$(function () {
    grid = lyGrid({
        id: 'paging',
        l_column: [{
            colkey: "id",
            name: "id",
            hide: true
        }, {
            colkey: "name",
            name: "名称"
        },{
            colkey: "jd",
            name: "经度"
        },{
            colkey: "wd",
            name: "维度"
        },
        ],
        jsonUrl: rootPath + '/school/findByPage.shtml',
        checkbox: true,
        serNumber: true
    });
    $("#search").click("click", function () {// 绑定查询按扭
        var searchParams = $("#searchForm").serializeJson();// 初始化传参数
        grid.setOptions({
            data: searchParams
        });
    });
    $("#addSchool").click("click", function () {
        addSchool();
    });
    $("#editSchool").click("click", function () {
        editSchool();
    });
    $("#delSchool").click("click", function () {
        delSchool();
    });
});
function editSchool() {
    var cbox = grid.getSelectedCheckbox();
    if (cbox.length > 1 || cbox == "") {
        layer.msg("只能选中一个");
        return;
    }
    var url = rootPath + '/school/editUI.shtml?id=' + cbox;
    pageii = layer.open({
        title: "编辑",
        type: 1,
        area: ["600px", "40%"],
        content: CommnUtil.ajax(url)
    });
}
function addSchool() {
    var url = rootPath + '/school/addUI.shtml';
    pageii = layer.open({
        title: "新增",
        type: 1,
        area: ["600px", "40%"],
        content: CommnUtil.ajax(url)
    });
}
function delSchool() {
    var cbox = grid.getSelectedCheckbox();
    if (cbox == "") {
        layer.msg("请选择删除项！！");
        return;
    }
    layer.confirm('是否删除？', function (index) {
        var url = rootPath + '/school/deleteEntity.shtml';
        var s = CommnUtil.ajax(url, {
            ids: cbox.join(",")
        }, "json");
        if (s == "success") {
            layer.msg('删除成功');
            grid.loadData();
        } else {
            layer.msg('删除失败');
        }
    });
}